package com.jz.entity;

import java.util.List;

/**
 * @ClassName PageBean
 * @Description 分页工具类
 * @Author MR_Liu
 * @Date 2021/7/23 0023 08:58
 * @Version 1.0
 */
public class PageBean<T> {
    private int curPage;//当前页
    private int pageSize;//页容量
    private int totalCount;//总记录数
    private int totalPage;//最大页码
    private List<T> list;//每页显示的数据

    public PageBean() {
    }

    public PageBean(int curPage, int pageSize, int totalCount, List<T> list) {
        this.curPage = curPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.list = list;
        this.totalPage=getTotalPage();
    }

    public int getCurPage() {
        return curPage;
    }

    public void setCurPage(int curPage) {
        this.curPage = curPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getTotalPage() {
        return (int)Math.ceil(totalCount*1.0/pageSize);
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "curPage=" + curPage +
                ", pageSize=" + pageSize +
                ", totalCount=" + totalCount +
                ", totalPage=" + totalPage +
                ", list=" + list +
                '}';
    }
}
